import { tradeRequest } from '@/request';


// 返回值类型:
export interface reqTrademarkReturnItemType extends reqAddTradeType {
  id?: number
}

export type reqTrademarkReturnRecordsType = reqTrademarkReturnItemType[];


// 品牌列表返回值类型限制
export interface reqTrademarkReturnType {
  records: reqTrademarkReturnRecordsType;
  total: number;
  size: number;
  current: number;
  searchCount: boolean;
  pages: number;
}




// 1. 请求品牌列表
export const reqTrademarkList = (page:number,limit:number) => (
  tradeRequest.get<any, reqTrademarkReturnType>(
    `/admin/product/baseTrademark/${page}/${limit}`
  )
)


// 2.修改品牌 
export const reqUpdateTrademark = (
  trademark: reqTrademarkReturnItemType
) => (
  tradeRequest.put<any, null>(
    `/admin/product/baseTrademark/update`,
    trademark
  )
)


// 3.删除品牌
export const reqDeleteTrademark = (id:number) => (
  tradeRequest.delete<any, null>(`/admin/product/baseTrademark/remove/${id}`)
)

// 新增品牌 类型
export interface reqAddTradeType {
  tmName:string,
  logoUrl:string
}

// 4. 新增品牌接口
export const  reqAddTrademark = (trademark:reqAddTradeType) => (
  tradeRequest.post<any,null>( `/admin/product/baseTrademark/save`,trademark)
)


//  所有品牌中的单个属性类型
export interface AllTrademarkItemType {
  id:number;
  tmName:string;
  logoUrl:string;
}
// 所有品牌类型
export type AllTrademarkListType = AllTrademarkItemType[]

// 5.获取所有品牌
export const reqAllTrdeamarkList = () => (
  tradeRequest.get<any,AllTrademarkListType>(`/admin/product/baseTrademark/getTrademarkList`)
)
